<template>
  <div>
    <el-table :data="datas.data" style="width: 100%">
      <el-table-column fixed prop="username" label="用户名" width="150" />
      <el-table-column prop="content" label="文章标题" width="150" />
      <el-table-column prop="image" label="文章图片" width="180">
        <template #default="scope">
          <el-image
            style="width: 80px; height:80px border-radius:50%"
            :src="scope.row.image[0]"
          ></el-image>
        </template>
      </el-table-column>
      <el-table-column prop="video" label="文章视频" width="180" />
      <el-table-column prop="time" label="发布时间" width="150" />
      <el-table-column prop="status" label="状态" width="150">
        <template #default="scope">
          <el-tag
            :type="scope.row.status === '已通过' ? 'success' : 'error'"
            disable-transitions
            >{{ scope.row.status }}</el-tag
          >
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="Operations" width="150">
        <template #default="scope">
          <el-button
            link
            type="primary"
            size="small"
            @click="handlealtbhs(scope.row)"
            >驳回</el-button
          >
          <el-button link type="primary" size="small">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
  
  <script setup>
import axios from "axios";
import { ref, reactive, onMounted } from "vue";

const datas = reactive({
  data: [],
});

onMounted(() => {
  getlist();
});
function getlist() {
  axios.get("http://127.0.0.1:3000/tyh/dynamiclist").then((res) => {
    res.data.data.forEach((item) => {
      if (item.status === "已通过") {
        console.log(item);
        datas.data.push(item);
      }
    });
  });
}

const handlealtbhs = (value) => {
  axios.post("http://127.0.0.1:3000/tyh/dynamicBhus", {
    id: value._id,
    status: "已驳回",
  });
};
</script>
  
  <style lang="scss" scoped>
</style>